package org.traffometer.packet.location;

import junit.framework.TestCase;

/**
 * Tests the functionality of the Latitude class. 
 *
 * @author Aaron A. Kagawa
 * @version $Id$
 */
public class TestLatitude extends TestCase {

  /** Tests the decimal constructor of the Latitude class. */
  public void testLatitudeDecimalConstructor() {
    Latitude latitude = new Latitude(46.17444);
    assertEquals("checking the latitude value in sexagesimal", 
        46.17444, latitude.toSexagesimal(), 0.0000);
  }
  
  /** Tests the degrees, minutes, seconds, hemisphere constructor of the Latitude class. */
  public void testLatitudeDegreeMinuteSecondHemisphereConstructor() {
    try {
      Latitude latitude = new Latitude(46, 10, 28.0, Hemisphere.North);
      assertEquals("checking the latitude value in sexagesimal", 
          46.17444, latitude.toSexagesimal(), 0.0001);
      assertEquals("checking the degree value of the latitude", 46, latitude.getDegrees());
      assertEquals("checking the minute value of the latitude", 10, latitude.getMinutes());
      assertEquals("checking the seconds value of the latitude", 28.0, latitude.getSeconds(), 0.1);
    }
    catch (LocationException e) {
      fail("should not throw an exception");
    }
    try {
      new Latitude(0, 0, 0, Hemisphere.East);
      fail("should not reach here. an exception should be thrown in constructor");
    }
    catch (LocationException e) {
      assertNotNull("exception object should not be null", e);
    }
    try {
      new Latitude(0, 0, 0, Hemisphere.West);
      fail("should not reach here. an exception should be thrown in constructor");
    }
    catch (LocationException e) {
      assertNotNull("exception object should not be null", e);
    }
  }
}